package cloud.take.off.module.common;

import lombok.ToString;

import javax.servlet.http.HttpServletResponse;


@ToString
public enum CommonCode implements ResultCode {
    //操作失败
    FAIL(false, 1999, "操作失败！"),
    EXIST(false, 10009, "数据已存在！"),
    SERVER_ERROR(false, 9999, "抱歉，系统繁忙，请稍后重试！"),
    SUCCESS(true, 1000, "操作成功！"),
    VALIDATE(false, 1998, "数据库验证错误！"),
    ERROR(false, 500, "服务器错误"),
    NORMAL(true,200,"服务器正常"),
    AUTH_FHIL(false, 10001, "此操作需要登陆系统！"),
    UNAUTHORISE(false, 10003, "权限不足，无权操作！"),
    UNTOKEN(false, 10002, "验证失败,请重新登录!"),
    ERRORPARAMETER(false, 10004, "参数错误"),
    LOGIN_FHIL(false,2001,"登录失败!!!"),
    LOGIN_CERT_FHIL(false,2002,"用户证书不存在"),
    BINDING_FAIL(false,2003,"绑定失败!!!"),
    NO_PHONE(false,2006,"用户未绑定手机号"),
    //    private static ImmutableMap<Integer, CommonCode> codes ;
    /**
     * refresh_token已过期
     */
    REFRESH_TOKEN_ERROR(false, 452, "refresh_token已过期"),

    /**
     * 业务异常
     */
    FAILURE(false, HttpServletResponse.SC_BAD_REQUEST, "业务异常"),

    /**
     * 404 没找到请求
     */
    NOT_FOUND(false, HttpServletResponse.SC_NOT_FOUND, "404 没找到请求"),

    /**
     * 消息不能读取
     */
    MSG_NOT_READABLE(false, HttpServletResponse.SC_BAD_REQUEST, "消息不能读取"),

    /**
     * 不支持当前请求方法
     */
    METHOD_NOT_SUPPORTED(false, HttpServletResponse.SC_METHOD_NOT_ALLOWED, "不支持当前请求方法"),

    /**
     * 不支持当前媒体类型
     */
    MEDIA_TYPE_NOT_SUPPORTED(false, HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "不支持当前媒体类型"),

    /**
     * 请求被拒绝
     */
    REQ_REJECT(false, HttpServletResponse.SC_FORBIDDEN, "请求被拒绝"),

    /**
     * 服务器异常
     */
    INTERNAL_SERVER_ERROR(false, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "服务器异常"),

    /**
     * 缺少必要的请求参数
     */
    PARAM_MISS(false, HttpServletResponse.SC_BAD_REQUEST, "缺少必要的请求参数"),

    /**
     * 请求参数类型错误
     */
    PARAM_TYPE_ERROR(false, HttpServletResponse.SC_BAD_REQUEST, "请求参数类型错误"),

    /**
     * 请求参数绑定错误
     */
    PARAM_BIND_ERROR(false, HttpServletResponse.SC_BAD_REQUEST, "请求参数绑定错误"),

    /**
     * 参数校验失败
     */
    PARAM_VALID_ERROR(false, HttpServletResponse.SC_BAD_REQUEST, "参数校验失败");

    //操作是否成功
    boolean success;
    //操作代码
    int code;
    //提示信息
    String message;

    private CommonCode(boolean success, int code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;
    }

    @Override
    public boolean success() {
        return success;
    }

    @Override
    public int code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }


}
